package cn.zcscloud.mall.interceptor;

import cn.zcscloud.mall.mbg.model.UmsAdmin;

/**
 * ClassName: UserHolder
 * Description:
 * date: 2022/3/31 17:13
 *
 * @author zjf95
 * @since JDK 1.8
 */

public class UserHolder {

    private static ThreadLocal<UmsAdmin> threadLocal = new ThreadLocal();


    public static void set(UmsAdmin user) {
        threadLocal.set(user);
    }

    //获取threadlocal里面的user
    public static UmsAdmin get() {
        return threadLocal.get();
    }

    public static Long getUserId() {
        return threadLocal.get().getId();
    }

    public static String getUsername() {
        return threadLocal.get().getUsername();
    }

    public static void remove(){
        threadLocal.remove();
    }

}
